import myRequest from '..'

type SearchOption = {
  keyword: string
  isStar: boolean
  isDeleted: boolean
  pageSize: number
  page: number
}

//获取单个问卷
export const getQuestionById = async (id: string) => {
  return myRequest.get({
    url: `/question/${id}`,
  })
}

//新建问卷
export const createQuestion = async () => {
  return myRequest.post({
    url: '/question',
  })
}

//获取(查询)问卷列表
export const getQuestionList = async (opt: Partial<SearchOption> = {}) => {
  return myRequest.get({
    url: '/question',
    params: opt,
  })
}

//更新问卷
export const updateQuestion = async (id: string, opt: { [key: string]: any }) => {
  return myRequest.patch({
    url: `/question/${id}`,
    data: opt,
  })
}

//复制问卷
export const duplicateQuestion = async (id: string) => {
  return myRequest.post({
    url: `/question/duplicate/${id}`,
  })
}

//批量彻底删除
export const deleteQuestion = async (ids: string[]) => {
  return myRequest.delete({
    url: '/question',
    data: ids,
  })
}
